<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title></title>
	<link rel="stylesheet" type="text/css" href="css/home.css"/>
	<link rel="stylesheet" type="text/css" href="css/pageSwitch.min.css"/>
	<script src="js/jquery-2.1.0.js"></script>
	<script>
		var status;
		$.ajax("/login/loginResult",{
			type:"get",
			data:{},
			async: false,
			success:function(data){
//                      在这里注册成功后跳转页面
				console.log(data);
				var dataObj = eval('('+data+')');
				console.log(">>>>>>>>>>>>>>>>>>>>"+dataObj)
				if(dataObj=="true"){
					status=1;
				}else{
					status=0;
				}
			},
			error:function(){

			}
		});
		console.log(">>>>>>>>>>>>>>>>>>>>"+status)

		$(function(){
			var search = document.getElementById("search");
			search.onfocus = function(){
				window.location.href="goodsItem.html";
			};
			function getUrl(){
				var str = location.href;//获取传过来的地址
				var arr = str.split("?");
				var str1 = arr[1];//获取？之后的内容
				var id = str1.split("=")[1];
				return id;
			}

			var flush = $("#flush");
			flush.click(function(){
				$.ajax("/fengwei/search/recommend",{
					type:"get",
					data:{},
					success:function(data){
//                      在这里注册成功后跳转页面
						console.log(data);
						var dataObj = eval('('+data+')');
						setData(dataObj);
					},
					error:function(){
						alert(0);
					}
				});
			});

			$.ajax("/fengwei/search/recommend",{
				type:"get",
				data:{},
				success:function(data){
//                      在这里注册成功后跳转页面
					console.log(data);
					var dataObj = eval('('+data+')');
					setData(dataObj);
				},
				error:function(){
					alert(0);
				}
			});

			function setData(dataObj){
				for(var i = 0;i < dataObj.length;i++){

					var goodsName = dataObj[i].goodsName;
					var goodsCity = dataObj[i].goodsCity;
					var arr = dataObj[i].fileUrl.split("\\");
					var src = arr[arr.length-2]+"/"+arr[arr.length-1];

					var goods_name = document.getElementsByClassName("goods_name");
					var goods_place = document.getElementsByClassName("goods_place");
					var goods_img = document.getElementsByClassName("goods_img");
					goods_img[i].src = src;
					goods_name[i].innerHTML = goodsName;
					goods_place[i].innerHTML = goodsCity;
					$(".goods").click(function(){
						var count=$(this).index();
						window.location.href = "details.html?goodsId="+dataObj[count].goodsId+"&userId="+getUrl()+"";
					});
				}
			}
		})
	</script>
	<script type="text/javascript">

		document.addEventListener('plusready', function(){
			//console.log("所有plus api都应该在此事件发生后调用，否则会出现plus is undefined。"

		});

	</script>
</head>
<body>
<div id="head">     <!--头部 搜索框-->
	<input type="search" class="" value="" id="search"/>
</div>

<div id="container">   <!-- 轮播图-->
	<div class="sections">
		<div class="section" id="section0"></div>
		<div class="section" id="section1"></div>
		<div class="section" id="section2"></div>
		<div class="section" id="section3"></div>
	</div>
</div>

<div id="option">		<!--图标-->
	<a href=""> <img src="img/benefit.png"/></a>
	<a href=""> <img src="img/mall.png"/></a>
	<a href=""> <img src="img/kind.png"/></a>
</div>



<div id="div_commodity">		<!--商品-->
	<p>为您推荐</p>
	<div id="commodity" >
		<div id="goods" class="left goods">
			<div class="goods_box"><img class="goods_img" src=""/></div>
			<div class="goods_msg">名称:<span class="goods_name"></span> <br />
				产地:<span class="goods_place"></span>
			</div>
		</div>
		<div id="goods" class="right goods">
			<div class="goods_box"><img class="goods_img" src=""/></div>
			<div class="goods_msg">名称:<span class="goods_name"></span> <br />
				产地:<span class="goods_place"></span>
			</div>
		</div>

		<div id="goods" class="left goods">
			<div class="goods_box"><img class="goods_img" src=""/></div>
			<div class="goods_msg">名称:<span class="goods_name"></span> <br />
				产地:<span class="goods_place"></span>
			</div>
		</div>
		<div id="goods" class="right goods">
			<div class="goods_box"><img class="goods_img" src=""/></div>
			<div class="goods_msg">名称:<span class="goods_name"></span> <br />
				产地:<span class="goods_place"></span>
			</div>
		</div>

		<div id="goods" class="left goods">
			<div class="goods_box"><img class="goods_img" src=""/></div>
			<div class="goods_msg">名称:<span class="goods_name"></span> <br />
				产地:<span class="goods_place"></span>
			</div>
		</div>
		<div id="goods" class="right goods">
			<div class="goods_box"><img class="goods_img" src="img/03.jpg"/></div>
			<div class="goods_msg">名称:<span class="goods_name"></span> <br />
				产地:<span class="goods_place"></span>
			</div>
		</div>
	</div>
	<span id="flush" style="display: inline-block;width: 20%;height: 40px;position:relative;left:40%;line-height:40px;text-align: center;font-size: 16px;background: gainsboro;border-radius: 5px;">换一换</span>
	<br/>
</div>

<div id="footer">	<!--底部-->
	<ul>
		<li id="homeGo"><img src="img/HOME1.png"/></li>
		<li id="schoolGo"><img src="img/school1.png"/></li>
		<li id="add"> <img src="img/add.png" id="more" onclick="showDivFun()"/></li>
		<li id="shoppingGo"><img src="img/SHOPPING.png"/></li>
		<li id="userGo" class="active"><img src="img/USER-head_no.png"/></li>

	</ul>
</div>

<div id="add1">
	<img class="del" src="img/X.png" onclick="closeDivFun()"/>
	<a href="releaseOrder.html"><img class="add1_imgL" src="img/fadan.png"/></a>
	<a href="acceptOrder.html"><img class="add1_imgR" src="img/jiedan.png"/></a>
</div>
<!--<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>-->
<script src="js/pageSwitch.min.js"></script>

<!-- 页面跳转--hbl-->
<script>
	$(function(){
		function getUrl(){
			var str = location.href;//获取传过来的地址
			var arr = str.split("?");
			var str1 = arr[1];//获取？之后的内容
			userId = str1.split("=")[1];
			return userId;
		}
		var homeGo = $("#homeGo");
		var schoolGo = $("#schoolGo");
		var shoppingGo = $("#shoppingGo");
		var userGo = $("#userGo");
		var add = $("#add")
		schoolGo.click(function(){
			window.location.href = "School.html?userId="+getUrl()+"";
		})
		shoppingGo.click(function(){
			window.location.href = "shoppingCart.html?userId="+getUrl()+"";
		})
		userGo.click(function(){
			window.location.href = "personCenter.html?userId="+getUrl()+"";
		})
	})
</script>

<script>
	$("#container").PageSwitch({
		direction:'horizontal',
		easing:'ease-in',
		duration:1000,
		autoPlay:true,
		loop:'false'
	});
</script>
<script>

	function showDivFun(){
		document.getElementById('add1').style.display='block';
	}
	//关闭事件
	function closeDivFun(){
		document.getElementById('add1').style.display='none';
	}
</script>
</body>
</html>